import React, {PureComponent} from 'react';
import {StyleSheet, View, Text, ActivityIndicator} from 'react-native';

export default class extends PureComponent {
    static defaultProps = {
        loadingText: "正在加载..."
    };

    render() {
        let {isLoading, hideLoadingText, loadingText} = this.props;
        loadingText = hideLoadingText ? null : <Text style={styles.text}>{loadingText}</Text>;
        return (
            isLoading ?
                <View style={styles.container}>
                    <ActivityIndicator size="large"/>
                    {loadingText}
                </View>
                : null
        )
    }
}

const styles = StyleSheet.create({
    container: {
        position: 'absolute',
        left: '50%',
        top: '50%',
        zIndex: 1001,
        width: 120,
        height: 120,
        marginLeft: -50,
        marginTop: -50,
        paddingTop: 28,
        paddingBottom: 28,
        justifyContent: 'space-between',
        alignItems: 'center',
        borderRadius: 6,
        backgroundColor: 'rgba(66,66,66,.6)'
    },
    text: {
        fontSize: 14,
        color: "#fff"
    }
});
